import request from '@/common/utils/request';
import type { AttendanceRecord, AttendanceLocation } from '@/common/types/attendance-type'
import type { AttendanceScheme } from '@/common/types/attendance-type';

/**
 * 查询考勤数据列表
 * @returns
 */
export const getAttendancesApi = (params: AttendanceRecord) => {
    return request({
        url: '/attendances',
        method: 'GET',
        params
    })
}

/**
 * 查询用户的考勤状态
 * @param id
 * @returns
 */
export const getAttendancesAdtStatuListApi = (userId?: string) => {
    return request({
        url: `/attendances/adtStatu/list`,
        method: 'GET',
        params: userId
    })
}


/**
 * 根据部门id查询考勤设置
 * @param 
 * @returns
 */
export const getCfgAtteItemApi = (params) => {
    return request({
        url: '/cfg/atte/item',
        method: 'GET',
        params
    })
}

/**
 * 根据部门查询请假规则设置
 * @param 
 * @returns
 */
export const getCfgLeaveListApi = (params) => {
    return request({
        url: '/cfg/leave/list',
        method: 'GET',
        params
    })
}


/**
 * 根据部门查询考勤加班规则
 * @param 
 * @returns
 */
export const getCfgExtDutyItemApi = (params) => {
    return request({
        url: '/cfg/extDuty/item',
        method: 'GET',
        params
    })
}

/**
 * 根据部门查询考勤扣款规则
 * @param 
 * @returns
 */
export const getCfgDedListApi = (params) => {
    return request({
        url: '/cfg/ded/list',
        method: 'GET',
        params
    })
}

/**
 * 考勤地图
 * @param 
 * @returns
 */
export const getCompanyListApi = () => {
    return request({
        url: '/company/list',
        method: 'GET'
    })
}


/**
 * 更新公司经纬度列表
 * @param 
 * @returns
 */
export const putCompanyListApi = (data: AttendanceLocation) => {
    return request({
        url: '/company/list',
        method: 'PUT',
        data
    })
}


/**
 * 根据部门保存考勤加班规则
 * @param 
 * @returns
 */
export const putCfgExtDutyApi = (data) => {
    return request({
        url: '/cfg/extDuty',
        method: 'PUT',
        data
    })
}

/**
 * 保存或者更新请假规则
 * @param 
 * @returns
 */
export const postCfgLeaveApi = (data) => {
    return request({
        url: '/cfg/leave',
        method: 'POST',
        data
    })
}

/**
 * 保存考勤扣款规则
 * @param 
 * @returns
 */
export const postCfgDeductionApi = (data) => {
    return request({
        url: '/cfg/deduction',
        method: 'POST',
        data
    })
}


/**
 * 保存考勤设置
 * @param 
 * @returns
 */
export const putCfgAtteApi = (data) => {
    return request({
        url: '/cfg/atte',
        method: 'PUT',
        data
    })
}

/**
 * 编辑用户的考勤状态
 * @param id
 * @returns
 */
export const putAttendancesIdApi = (data: AttendanceScheme) => {
    return request({
        url: `/attendances/${data.id}`,
        method: 'PUT',
        data
    })
}

